

#include <cstdint>
#include <gtest/gtest.h>
#include <string>
#include <vector>
#include "../rtmp_parser.h"
#include "test_util.h"

TEST(RtmpParserH, RtmpHeader)
{
    std::string test = "4300000000002314";
    std::vector<uint8_t> data;
    /* std::string n = "c3"; */
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    RtmpMessageBuffer buffer;
    buffer.PushDataToBuffer(&*data.begin(), data.size(), use_length);
}

TEST(RtmpParser, ConnectCommand)
{
    std::string test    = "030000000000891400000000020007636f6e6e656374003ff000000000000003000361707002000361707000047479706502000a6e6f6e707269766174650008666c617368566572020024464d4c452f332e302028636f6d70617469626c653b204c61766635392e31362e313030290005746355726c02001972746d703a2f2f3132372e302e302e313a3139c333352f617070000009";
    std::vector<uint8_t> data;
    /* std::string n = "c3"; */
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    int status = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser, SetWindowSize)
{
    std::string test = "020000000000040500000000002625a0430000000000191402000c63726561746553747265616d00400000000000000005";
    std::vector<uint8_t> data;
    /* std::string n = "c3"; */
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    int status = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser, ReleaseStream)
{
    std::string test = "430000000000231402000d72656c6561736553747265616d0040000000000000000502000673747265616d";
    std::vector<uint8_t> data;
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    int status = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser,CreateStream)
{
    std::string test = "430000000000191402000c63726561746553747265616d00401000000000000005";
    std::vector<uint8_t> data;
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    int status = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser,PublishCommand)
{
    std::string test = "0800000000002414000000000200077075626c6973680040140000000000000502000673747265616d0200046c697665";
    std::vector<uint8_t> data;
    HexToData(test, data);
    RtmpParser parser;
    int use_length = 0;
    int status = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser, MetaData)
{
    std::string test = "0400000000021f120000000002000d40736574446174614672616d6502000a6f6e4d65746144617461080000001200086475726174696f6e000000000000000000000577696474680040940000000000000006686569676874004086800000000000000d766964656f6461746172617465004099954a0000000000096672616d657261746500403df85452cec4fb30000c766964656f636f646563696400401c000000000000000d617564696f646174617261746500405f3ff000000000000f617564696f73616d706c65726174650040e5888000000000000f617564696f73616d706c6573697a65004030000000000000000673746572656f0101000c617564696f636f6465636964004024c4000000000000000b6d616a6f725f6272616e6402000469736f6d000d6d696e6f725f76657273696f6e0200033531320011636f6d70617469626c655f6272616e647302001069736f6d69736f32617663316d70343100057469746c650200265370616365582773204352532d32313a20546865204669727374206f6620697473c4204b696e640009636f7079726967687402005d466f7220636f7079726967687420616e64207265737472696374696f6e7320726566657220746f20687474703a2f2f7777772e6e6173612e676f762f6d756c74696d656469612f67756964656c696e65732f696e6465782e68746d6c0a0007656e636f64657202000d4c617666c435392e31362e313030000866696c6573697a650000000000000000000000090600000000002f090000000017000000000164001fffe1001b6764001facd1005005bb016a0202028000003200000bb5078c188901000468eb8f2c040000000000120800000000af001210000000000000000000000000000006000000000414090000000017010000210000040b25b84005dffef527f814d508444be16b61edd4b74930d170b12db3d000000300000300000300000301f58bffdbec6fbb8f3837a4bfc0f25a0bcb2a848b39c0bfc203f63666bf96f1b5e64005f3979b728381c0e070381c0e070381c0e07d6ee070381c0e070381c0e070381c0e070381c0e070385d7703c681c0e070381c0e070381c0e070381c0e070381c2d50381c0e070381c0e070381c0e070381c0e070381c0f6f8e070381c0e070381c0e070381c0e070381c0e07039378e070381c0e070381c0e070381c0e070381c0e07039278e070381c0e070381c0e070381c0e070381c0e070391e40e070381c0e070381c0e070381c0e0703c681c0e0704fb70381c0e070381c0e070381c0e070381c0e070381c250070381c0e070381c0e070381c0e070381c0e070381dea381c0e070381c0e070381c0e070381c0e070381c0e39870381c0e070381c0e070381c0e070381c0e070381c728e070381c0e070381c0e070381c0e070381c0e07037871c0e070381c0e070381c0c6e070381c0e070381c0e06ee2381c0e070381c0e070381c0e070381c0e070381c0de1070381c0e070381c0e070381c0e070381c0e070381bc68381c0e070381c0e070381c0e070381c0e070381c0d60070381c0e070381c0e070381c0e070381c0e070381ac50381c0e070381c0e070381c0e070381c0e070381c0b2381c0e070c6381c0e070381c0e070381c0e070381c0dff2070381c0e070381c0e070381c0e070381c0e070381aedc0e070381c0e070381c0e070381c0e070381c0e070030381c0e070381c0e070381c0e070381c0e070381c0d74e070381c0e070381c0e070381c0e070381c0e07037fec1c0e070381c0e070381c0e070381c0e070381c0e0c66c770381c0e070381c0e070381c0e070381c0e070381c0120e070381c0e070381c0e070381c0e070381c0e070368b81c0e070381c0e070381c0e070381c0e070381c0e00981c0e070381c0e070381c0e070381c0e070381c0e060870381c0e070381c0e070381c0e070381c0e070381bdf70381c0e070381c0e070381c0e0703c681c0e070381c0370381c0e070381c0e070381c0e070381c0e070381c0c68381c0e070381c0e070381c0e070381c0e070381c0db8381c0e070381c0e070381c0e070381c0e070381c0dee381c0e070381c0e070381c0e070381c0e070381c0e00c81c0e070381c0e070381c0e070381c0e070381c0e06781c0e070381c0e07038c61c0e070381c0e070381c0e06ce70381c0e070381c0e070381c0e070381c0e070381c02b0381c0e070381c0e070381c0e070381c0e070381c0c60381c0e070381c0e070381c0e070381c0e070381c0d94381c0e070381c0e070381c0e070381c0e070381c0df7381c0e070381c0e070381c0e070381c0e070381c0e02081c0e07c60381c0e070381c0e070381c0e070381c0e0d9a40460000210006c7092701000021000006be21e21c8d7f91cfbf81f207ce081859b93bba2a3bada3e78fd70085db26b3e124337423a0796e51831edad1851e5ce2695559e9c528d35f9c7b6bc7e2f32dff9d57af82165c67051b90fbb6d05a64748ce8048a87a767544127d1c8f23b5937a3326cf41b021e2b6c9e89cbe6c039ec6d702850a1442217c6b518df0d6e3313c5370a84dc39c8b965ace8abf57eb0d18ca92d3025702850b69d9c8a11073ceec6aef62850a13d5c5589e49e2de908836b81428472142850ab93b7f77447c252aa9a0276d6671e0b3166294142850a14285303688a751a719b5f22ee7c7cd42ece52c7c508f51a670eb71412567400a95fb228142850a13c2ec61ed8fcbed6e4622d70a6b147f03bfad8dcacedbc5fd3eb7cb415ff38f93b47f82e27e4565d47a5a302924cc2ca5974dc2729bd6deb6f56fadbc7eaef13925a96deb6dc06f5b555be6ce932dfef5b7adbd6deb6f5b7adbd6deb6f5b7adbd6deb6f5b7adbd6deb6f5b7adbd6defef4af201bbb00765da626d9266e6cfe10fc856cc6cb7021da92112282c9ed1aaf67bc60513924c9a84d426a13509a84d426a6d8b375909766b540af82eb064c533514fb1c81f468997ecb0627320aa9618f509b95edb7adbd6deb6f5b7adbd6deb6f7f7b3c37777ea427f7b2eb252d4146f60d8286bb8fdbca441552c31ea1372cb153253ae4aaef7f83a113baea7bc2eb0ecfd11c6aa65fac4d4ce2e3312e5c4d1ea24eeaa79dad287e97c1eadebff8248ff79dee57d5404a635872e0453eb0e7216dcb868f8013f7ef29d871dbcf3bb1abc0a0e2eecb85218eda176ab0bf3ceec6af611e3b1fdbb157d25ba70db0e8142850a14284e210a142850a14285092e21519d0b87de142850a142850a142850a142850a14c62850a134d0c9c2e5bc53c5bd21106d702850a142850a142850a142dc0689d0662a0de2ab87237168f937c2142850a142850a142850a2ed2c31fcfee4c2626522ccf4a17a6819dd8d5e050a142850a142850a5b1b511e0afa71ab362553dc226a743a6db0c22f02850a142850a14326fd378d528f5c931e15f7267dc2d4669767c6cc324dce45b610a142850a142a7cd8d75cb3a0c3fd5e77635803ec910a75d06339c8b6c2142850a142884a8239ff590ca31222941e485df4b23118e8c6ccf81fd109d0e5e29ad7141eb52989678d9cd8f3f0e31e0cba843045d07f7e46e5f3c11e9e9e19d8db6d796e48b4c1512e06b28c9f107215475d610d924788cc3c0af6c693016652cbfaba329cdef4ad8d059c3bca57ca66ebf899eaa57a276d608db967899a04f8c204ab9aa00694fee1f062409c58f8abd7b0feda9763f72a5a079aa87cadd6a74cdd9c85cd22429bccb808b2c5fabd9b95feec7d4e9f59a55dd9c7b92c5abb9c357eaf55fd2ae1dc244b3bcaca0b8f39de2fea8c386b2ce42113d12cc6e111fcf6b4425964f2cb67b1d1e849c98796a9a94e7701466e2a7de19605d030465d82cda2f59c2d321c8c2cca6985b3ab75e3b535d079297548a34dabb43a4d691d058b17216bc6f6630b5bd48ea40dc2b0945ac0dacf549e957e596d66b144c784340a125a1be601800417fa616781428509f813513deb284a0670ad4a8220c60da0e7a5ba56ea5adea46148dbbb7551415ca28ad0bdb5de30dbd7bdea1b5d0a0d9ee9e0a609cf9ba3d835bd7544e063edf5da342671fc220e79dd8d5e05bb3d7c330fcbc6be7ccb94d82ee6be74d1f30fb1451518aa3bb1abc0a142843bd01cc28445ffa616781604212707955a51a3983d6e0765fadbab01bd39f1de63f26fc6842850a142850a14285bab45880bdd9381f1fa719ce45b610a1428583acaa7de3d8337a6628445ffa619c8887c0a9724132c5c85aa8e908836be90438f014792b6aa94e27ea47e0c282ea5012965d8c73446260444e1aad3778c58de45c85abb0ec2b64b6cf429fffe0fa45beb1525a09edfce855b252c99fd7170da8098119bc6e78982f61b41f33d1e79f5d177f8e1c63ab04b8b1f09e9f43a19b4c321e672fb9f82e7ab2595cc727b1b880b9175e92ecd1416672f3991cc4903ef03bfcd4906f0fad66fc128d88b90a8b2012731be380e192439ed9aefa4a93c46a1bef368d78bda32246b995ac7a033af0eaa2ec1db011e5d44e8baa4ef6476fbad3a7c6111c6e38a445ef4e8721f5b7945c60d9d60c212afd9b5f7a96a220fa296e9c6f29f98cd37584f92282a19b50537bceeb348168b0f6d291a56578467736549340a3b2a688162cc54904ff88a83a9197a2f54a02d2e95eab26f10a966fb22c6c722ce5b124385df48841f133bf24cbb9c4eec51610142850a1428438842850a1425f2d0c6a142850a142850a142850a142850a142850a14284fd0a142850a142850a142850a142850a142850a142850a16f507616aa3a4220dae050a142850a142850a142850a142855c76e4400002100017508af0121000500a01bffc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c40000000000000000000000000000000000000000000037a700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b4400001700017608af01211a931a7c6080000002000d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d8046d88b5b116b622d6c45ad88b5b116b622d6c45ad88b5b10ec69f182000000080036011b6011b6011c4b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b6011b622d6c45ad88b5b116b622d6c45ad88b5b116b622d6c43ef8a0000000000000000000000000000000000000000000000000000000000000000000000c4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ef4600002100084c0917010000220000084325b820025ffede23c0a60e9f45d573c6f9e031f156ee9b471cee3c23687c5d40021fe08038a0620257ae51b947734181792df8ca144933da839b0400961b8de22d939b27021743c344b45b1a3d480d35bfd877058b632b26ef2867fb48d7d998546f05c8345af98048e8fe791c18502b3e455a633a33a5c6c05e05e22eb168564a3a16f60ddf7eca169f9673289cf8483ecb85f14e5ebc1594c8f028baaccc4db94bfdc185a4766d8053e2cccfe435d614d707d1b9d62d6e9c263706ca1c4aabf661c8e20df48361c4473725c6c6fc9cad29e5d64fe9a9c7076db6add77de385640aca9b03403b9838166487ae57b6705fe67864518b1033c6c6fa59d6e5c18ccd4dbbf158ad1c14a7ff921cc3bcb212bc22311aecf7be213e7840d1937c87df624a007c77bc41bee8991febc05964679e86d4d41f4f509901fd64785f8bc0a3240138b86041287379342d8679b5b8525e5d63e1377e93705abffd46800bb73e7839a2341fbfb76841af46e7cfe20126a670b366de99b7533dc6b6a69ded444e37ec30453ffa0d84e578aaeb678822e4e6b2396ce1cb48397e2f32a2f40f0d783862db0aa777702cd701ea0f4252cb646455e8eca4770d2dabd91801157598a34b571426fd35a42a4b94ab9fb6de8e29e50b0ebfad28bccfb6187d8eec2534c17ef771c0313143c27ebb66245c6ae1e2d67bf56b6868d29deaf2c63305546775936554e4c4d394bf56d240572787abc2be3860cb29afad85a9865c67ba7f883350cfd1301f5afc015efa57f096c757ad766c60ade197f4e97d2e66cf6d124a4f25d565921dcf774c5e250a5677dfa52ea5bb46b7d0cf1bf1e6e087e0415963d4f2dc99d2aefb194dd36420fbcd51bb769327e7aa8852f622b49a12c6e5fb6b5a9a548ac3e5897098309a14d1d54e49018b035943accdee1d2a30868c731ae6464e93bf9d54e333cbafe3eadd013a18196f878cc95470bf04cff237d9f810f47931bec73f6700eee2153917c97b985ffe03230718ad24120cbda26b5cdfcb5baba3061c8632831a763a9a2ebc642c5d04303c2132b7de64ba0e6aef96c66625840684bd099813f3150457457c00e42fae546afca790124e50e648cc5fbd142f92ec04d9971e96567bdf1abd740ea2854b1d1b0b0ada50d51697b0987e12fcb4cacfd88d61af40727b639342bfa1b68d6db1a90ebaa4cd902d71d10615813a278346b887b04945994251257f5a4876beddf50484da86a64c93612ce1556dc668166a436e91d14b85f1cf1426ab2396f8fa27cd153c965b877ce25e5ae09582a6b025dbda182b2331748e4ac8835a5d80e2c11f374c258896fea5245b7aeb7cb54f79e836329565abeae5e4640617ce79e6899a19d713606e12952922725d3645663914dafd284efb09dd2e337db5d83530c200405db140f6eaea7110fbf094c60a94655d4e00e34c4b8a31654e9cd4e0f0b8289a66782181cf4377ff65d35a9e765a7ca5d134be9ec4e18c1d26cee722c046b84678d3e201286d7d60134db324fce349ec6f6a8eeb2997e65aaa57a04f394dde0c56a23eb5eeef2f072f22b69c7f325b3fe6c38c5f2f6ca10d6721f34f644d141b00340449fd6b2c95813b32a9c65a76fc1020b63ca2120bf949fa0117a3dfe9c2cd25fc0d51a3127c7d98701909847cbcb498c65d6321e23eebab5b4858c61bdbba4272c2d357586edf358254d82a315b18d788fa12800627c5efa41dcaf86027afa2936ae6522f13e4f9897441e6d57261284945766855a70b52621bd972c34e3ac80c2c3116f7e6445374e0d3c647393ad7d766112d6eb6021022997722dc2865f3dd6eba08c81016fab6a7b070071c578b6b6b06e574ddd8ee6a9306a3f6889bb5bbafeef2b4b5182683e34de750af1dd8aca5804e70c19808501db12a204421a0a0e85776fe0c5b603901d912ea2a069f6ddc880f7002277169377da8ff4298bfdeb75b39bd32d4275116f56bc6d96c1237f0c99bb68ab542376dd0d972e7738b2358056c59c6b81a4f37d8cdfa4b158fed2bec79c0bc0f134942f35b33b7a1063d0c2876a35d5bdb4744a91eea74233f4e07e1db9c30ce0eb7a93a2ae9399ef5aee84ca780aec05ed84dd2ce51f3fe5a22ae006dcd718d320277cad2f7a6dec52c5f6e25fc0393dc6a78175512c62f4b3c57b34ccfae59b43f4bbca4575582e06ad8e59f3d6229ad42f22af7a44773fcdaf037dc096b2699c4f56de527d65be1eec9f671d1c6cea03fbda87373ecdbc11eaa58cb88893e409ff1f6631d5dacd830fba2acdf6cad0e763985ee9aea695f24dca2de940e8c68cc28daa5f42358eed8c2a2e39e7dc7fbcfa7b6507188c6cdad6007687c54ea3c04551e0ec6db4b6fd064c22384b1234f661627523b6fb7356e1a273483082854f584060378b12e5f568b8d2dc52fc06cb5e2ef8f859141fbe7da38c17d98a0d0941758c90638e39e3f7cba9d21210a20dbfc8b501721bbfd59dfb0f604e8181cfb5a371e9ae8f5480d8bccdd8f63cf0c0a116d46b935d9c6f29fead4a114860e4df95f346e8df5de108d5a762d8f0d5979e9c59e2669d20a3b38fd654eb95fea6ce7e3c142e616d7904e6cf692e79464b879ebecd28f5f9238feb521c7982b265623909fcf47645d850932a1453cdbb4de98737763aed0abc1df4ef9fb3b09c06a56b461ea330b5dad32b9686fdd5104e4c28ed1030b4ccac66e638443701d1bfa2dbc4157e0a4d1b448df67096c1193eefd884ed7702a6b358c8914622390281dcf7cc58c30e5830515a3a72a199d9298d1ea7c97ac4f3024fa68f1126b3c1926ff7ea6b031a84e264452e9798bea199a381bd1374ce48a9c0d46145aca1fd22bf3fa7c628c62af0bb95638204e021961ad254a97b4a1c469c6fcf8e295b3cb1d0f546c61278cba25d3c322631aff73beca69ac90975d6a5fbfb186f9174da74a17febeea8a8adf923e64b73484da8357b25030005c4591e6c5c8287cb4f9aec44b8293df68";
    std::vector<uint8_t> data;
    HexToData(test, data);
    int status = 0;
    int use_length = 0;
    RtmpParser parser;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), use_length, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
    use_length = 0;
    RtmpMessageBuffer buffer;
    int index = buffer.PushDataToBuffer(&*data.begin(), data.size(), use_length);
    INFO("parser rtmp message size:{}", index);
    for (int i = 0; i < index; i++)
    {
        auto msgi = buffer.PopMsg();
        std::string content = msgi->PrintRtmpMessage();
        INFO(content);
    }
}

TEST(RtmpParser, AudioDataFrame)
{
    std::string test = "4400001700018808af01211a938daa94c83180c50837acb2a64094002c06b26693f94085a7fad0bc433d8bc1f1d59618860f05624221130c43258499231309fd9f261c84027d73ae321949310d7fa4fb2597bfe41f3f51e6091f7d5f64ef9649aaa47abaf28c49bc42b90e0b116094ce3dfe20164491198b1112b8f95f6e39f7fc5844912fe8e613c4c4294f9753dc994e99e9b17ec9bcd4d44aff1e8594294e6594258a0a50c25109085764c59657421a1beec59fc7ac9a64d3678f216aa668d275a53acd6a80678fe5159400b7eda6a69fc8d02bf353ef594a272b4d2d8c840188c0a214056da432e014016d648c43a0428fbdc604009211e6d89189be5125008385a48847b442aac4f2ba2cf260e02664932839bdf4d11870999f4319a48381b197eca30b11641d8ecf6b682a03b993551921c61a480a6e0ec6988759c68acf0c60db079f8d939d42a8cb6a8d39c0d66b3e591465f18ded9d9250e4666051b65823955480a34fedede3538be8f3f6ac3efd26240022db9fa392f070f6ec7dcb51cf548d3f96b8e87ec410f98f9de159d8e9";
    std::vector<uint8_t> data;
    HexToData(test, data);

    RtmpParser parser;
    int status = 0;
    int lenght = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), lenght, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);
}

TEST(RtmpParser, VideoDataFrame)
{
    std::string test = "4600002200073d0927010000210000073421e21c99ffbb6027a0fec477a0d6756e7810d6b958b56d742c2e7bbf917c145eb6661d990871b49485e6591091ad7b642cae8b8fac42b7374d2e857812e5d052736f6ee04906734f8bdf92004c22b83fd5a00dffb7edb5c2608b599b63fceaec8876a97acb7e15635a2ecf1dc6b6774c304cca15ac4ea3c6fecc32f93e635900c5e0134af9f989bb565f649c6106996e22c5bee5f844061b4c6547892036cdd8e9acfeae3060429fd282d6b194b1f0c27d13722e692a5698d446e6543a532766a303960029bd336a16cc56ff11eb51bfaf33d64bc5933313960b05e5915d280f9481641f98beadcf55a74193caa965eee8f190270cc50fc3c6a53c87b0fb5d6272393dc2e6a33da53f7d6b4984c858ab6671a827278f402053324503f4b13ae1aa3c5a97dcc0dcc1df06d48fa643dbe0a0a8b3e8baac5a3765ffa00d595d48f3b8b183a377951a4f924da8b0b39d1a0820fe717fc40f487e2e37b82332f31e59cd284bc2c06787c3a2a18e3f855a1282070f5bc4f2c3edf998c63756b656d6db2e73a20d9ae51f6051fd6f421e5bcfef2d842a3785580e5005b63b01953b789c3f4cb012b36ce30073fcb9404aca75d5c8bc963fbb4d566124371cadf5a75f046ddbea5f6c4c2e97e4ad36ec8b6989d2079ae989b940e7a8fbd3706410d17009027e03513043a46be00da20bea6d788083796c308e592c13de82c6fc3ea68b7d521f7f3064e371ecd385865cf3b57415c571132bb70fb4ca5104c135f28e4c5d4fd01528d56a7ac3710163f572b31878348cc23585499b76394b00becdec9d5aedc828d2b39113764272edec6d4c2dc2e97a2dbb5beb2886080c1fbecd05f698835983dfec00087ef1cb2135e8fd219946f0aed4e3dcbbe895f7ffc62bec5d76de911f6ad32f5f8d15142b21bb2968ccf581a25ad78a664c3219d584851786bef31ec45472eab2e35ba45c55015f35bee1de038e1714b66aea4a0e8d49bac47b0d4729072a26e07b949aba2b75c5da020dff1f42446444f7025a4ad224633063945d3d15be8a1b1dfa7a72f18e9eff9e8fc14937d1bdfd97ca319d67c6954f1ccbbdcd5aad7a1cbddacbb1e976fe6c947b6640aff9c9c214e627433da06c5c830823e485a38ba04978aed58cc128479256314c2545b18a9b8aefcf5ee72776273da00fcf1bdd1e9e81f1a37d9ad52655a0aed1b0d229e056065ee360d8b6b4c02223a6cfbe3f959f05750b523a0cbe5aa5264629cbdaae7fcb74c82465c61348327bdbfb840bc7c2574f75564588d0fd71434ebf2e82373785d15126a5b1571a59377bc52f1d72fdfe1e2a51e48d29a3bbe5bda2f73f3003936f8b718263ade593e40626e7d47335c7b5d9109dfe902ff638907c832d9cb25766c8461892ab75361b104e6245274fab28cd81757181d431be19e3ef0c99903d7b64e88680c6e27e0847dc38bd6641a2cca2bf9a3f2f0236c61fcfb707f51185320ef3e75162428c9a9796109af5cd3c20d1eb23d16f0f5349328b64debe70de8dc8cc818c94573307806b024aa275892456b60b0842114239816573b5891ae93586cb41dc76afb1ab88dbf95fc069b148be603751045e0a66ef0a84d63e63b4f2aa7659d4bac6ce3b1f9fc170fc29c4cee863cb796858dc59e628d8d2afe47600a485899badd82e61376d5a978f59df40b00184572ff8dea9e248dc927d212448ca25a42c0583db45853841467ce679bb769d062298412f94bbb71b873a1bd208ccbff22e9f9d7d9bcf2f4c16fdf908e7efd5acfb166fe7731606dc676bb20632c3b658c62470c6d1b5f9ec6fbd2c251932deeb91e81f2695abaa41561ca666859c90052928ff14f961a8316b4fe81ac5d852ecb7d544adfeaf42bcb21c5d740304c79eccf79186e4ad17dd10cd888e7fd414612f03b8ca038b86b9f4d4e8d7e9cbc87814dc702ef5bee280e03055c92a8f399278d1b84e1d34e6410959018e7ed8d023a7129217c606f8ceb91e6ffee14c7dc42f488477d47b3859c6a888ea90ee2ff5f781e4e215a6a19591e0240f7dd5832e28f0b1394720e2ce24d798253e7aad468da3ebd65e13c8e64474a48dd449c56e226f7a51d4a5454d8723f68f12311ecfc9ff188d5e521d2c5ead96b153d74681f9d8558705e2edfdbbd9fbad12a5453f442ea8de61c6cbc0aa40b22a2a57c708c7a8fb7dc0ae214805922d1f7d8f56f2d6f1b6592a8adad8c87f508e3a91ad560b783e2486304444bf850ac72f378fc1cfa0bfd6fe0a27f0ff6d920007df0f7b59e2de9bed25bdf546f1982ef96ffa229f46ca9ae2edc88e297d6f277e11dfd82d4635626ee3828d7fc5a7e457a6493922873bb2e519c642ee119f9c4bf9ab627aae98313ee42d11979460062fe1c606a441e9971c642ac838b036be880fec2c9523bf75c90df64f2efa8081e6213bfb516a3ceaa349f749d3ec9e8075fbab85b0209ab495052ebf425e864c692ac08819f9463e63fbc8ca152fd03f5189c2e073d3cafff92145cb35912fe37300d8bdafb489160be3aac62bbf40f6f56434e77364dc0a5b9fa5bbdc62242aecb7c26b92626a6260558ccca66c6ab17678da55f6309214ada4e9c3707e90357625c5a90eef1054b7";
    std::vector<uint8_t> data;
    HexToData(test, data);

    RtmpParser parser;
    int status = 0;
    int lenght = 0;
    auto msg = parser.ParseRtmpMessage(&*data.begin(), data.size(), lenght, status);
    if (msg)
    {
        std::string content = msg->PrintRtmpMessage();
        INFO(content);
    }
    EXPECT_NE(msg, nullptr);

}

int main(int argc, char * argv[])
{
    testing::InitGoogleTest(&argc, argv);
    LogModuleConfig config;
    config.m_log_level = "trace";
    config.m_file_name = argv[0];
    LogModule::Instance()->InitModule(config);
    return RUN_ALL_TESTS();
}
